package apiday02;
/**
 * 验证匹配   返回值boolean matches(String regex):匹配
 * 使用给定正则表达式
 * */
public class MatchesDemo {
    public static void main(String[] args) {
        /*
         * 邮箱正则表达式：
         *   [a-zA-Z0-9_]+@[a-zA-Z0-9]+(\.[a-zA-Z]+)+
         *
         * */
        String email = "kkktedu@com.cn";
        String regex = "[a-zA-Z0-9_]+@[a-zA-Z0-9]+(\\.[a-zA-Z]+)+";
        if (email.matches(regex)){
            System.out.println("验证成功");

        }else {
            System.out.println("验证失败");
        }
    }
}
